#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/9

import threading

import time


# 直接调用
def sayHi(num):
    print("running on number:%s" % num)

    time.sleep(3)


if __name__ == '__main__':  # 主线程
    '''
    t1 = threading.Thread(target=sayHi(1))  # 生成一个线程实例
    t2 = threading.Thread(target=sayHi(2))  # 生成第二个线程实例
    # 在主线程中启动子线程
    t1.start()
    t2.start()

    print(t1.getName())
    print(t2.getName())
    t2.join()  # 线程等待
    '''
    t_list = []
    for i in range(10):
        t = threading.Thread(target=sayHi, args=[i, ])
        t.start()
        t_list.append(t)
    for i in t_list:
        i.join()  # 线程等待 顺序执行
    print("----main-------")
